<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>MUMMY</title>
	<!--<script src="head.js"></script></script>-->
	<script type="text/javascript" src="js/mummy.js" charset="utf-8"></script>

</head>

<body>


<script type="text/javascript" charset="utf-8">

/*head.js('mummy.js','essai.js',function(){*/
	
	Interface(
		function IHuman(){
			this.firstName = "";
			this.lastName = "";
			this.sexe = "";
		}
	);

	Interface(
		function ILiving(){
			this.walk = function(){};
		}
	);
	
	Interface(
		function IAlien(){
			this.fly = function(){};
		}
	);	
	
	Class({
		$implements:[IHuman,ILiving],/*implements*/
		$define:function Human(){
		
			this.firstName = "John";
			this.lastName = "Doe";
			this.sexe = "???";
		
			this.$properties = {/*properties*/
				FirstName:{
					get:function(){
						console.log('get firstName : '+this.firstName);
						return this.firstName;
					},
					set:function(value){
						console.log('set firstName : '+value);
						this.firstName=value;
					}
				},
				LastName:{
					get:function(){
						console.log('get lastName : '+this.lastName);
						return this.lastName;
					},
					set:function(value){
						console.log('set lastName : '+value);
						this.lastName=value;
					}
				},
				Sexe:{
					get:function(){
						console.log('get sexe : '+this.sexe);
						return this.sexe;
					},
					set:function(value){
						console.log('set sexe : '+value);
						this.sexe=value;
					}
				}			
				
			}
			
			this.Human = function(first,last){
				this.firstName = first;
				this.lastName = last;		
			}
			
			this.walk = function(){
				//#I:BEFORE
				console.log("I'm "+this.firstName+" "+this.lastName+" ["+this.sexe+"] and I'm walking");
				//#I:AFTER
			}
		
		}
	
	});
	
	var PCE = $(Human).getNew("Philippe","Charriere");
	console.log('1- '+PCE.FirstName+" "+PCE.LastName);
	
	console.log(PCE.interfaces[0]);
	console.log(PCE.interfaces[1]);
	
	var TOTO = $(Human).getNew();
	$(PCE).CopyTo(TOTO);
	console.log('1- '+TOTO.FirstName+" "+TOTO.LastName);
	TOTO.FirstName = "To";
	TOTO.LastName = "To";
	console.log('2- '+TOTO.FirstName+" "+TOTO.LastName);
	console.log('2- '+PCE.FirstName+" "+PCE.LastName);
	
	
	Class({
		$extends:Human,/*extends*/
		$define:function Man(){
			this.sexe = "MALE";
			
			this.Man = function(first,last){
				this.Human(first,last);
				Man.Counter+=1;
			}
		},
		$static:{/*static*/
			Counter : 0
		}
	});
	
	Class({
		$extends:Human,/*extends*/
		$define:function Woman(){
			this.sexe = "FEMALE";
			
			this.Woman = function(first,last){
				this.Human(first,last);
				Woman.Counter+=1;
			}
			
		},
		$static:{/*static*/
			Counter : 0
		}	
	});
	
	var BOB = $(Man).getNew("Bob","Morane");
	var ALBATOR = $(Man).getNew("Al","Bator");
	var LARA =  $(Woman).getNew("Lara","Croft");
	
	console.log('TOTAL OF MEN : '+Man.Counter);
	console.log('TOTAL OF WOMEN : '+Woman.Counter);
	
	BOB.walk();
	ALBATOR.walk();
	LARA.walk();
	
        Human.prototype.hello = function(){console.log("HELLO HELLO HELLO : "+this.FirstName);}
        BOB.hello();
        ALBATOR.hello();
        LARA.hello();
        
	Class({
		$define:function Wolf(){
			this.Name = null;
			this.howl = function(){
				console.log(this.Name+" is howling ... waooooouuuuuuu");
			}
			
			this.Wolf = function (name){this.Name = name}
		}
	});
	
	var GANDALF = $(Wolf).getNew("Gandalf");
	var TUTU = $(Man).New();
	
	
	//$copy(BOB).to(TUTU); //à faire sur le même principe que new et implements ???
	
	$(BOB).CopyTo(TUTU);
	
	
	//$merge(GANDALF).to(TUTU);
	
	$(GANDALF).MergeWith(TUTU);
	
	TUTU.walk();
	TUTU.howl();
	
	console.log($(PCE).Implements(IAlien));
	console.log($(PCE).Implements(IHuman));
	console.log($(BOB).Implements(IHuman));
	console.log($(PCE).Implements(ILiving));
	console.log($(Human).Implements(IHuman));
	console.log($(Wolf).Implements(IHuman));
	
	console.log(BOB.getType());
	
	console.log(BOB.getTypeName());
	console.log($(BOB).Is(Man));
	console.log($(BOB).Is(Human));
	console.log($(BOB).Is(Wolf));


</script>

</body>
</html>
